package com.anXin.domestic.controller;

import com.anXin.domestic.service.DomesticResortService;
import com.anXin.model.common.dtos.ResponseResult;
import com.anXin.model.service.dtos.DomesticReleaseDTO;
import com.anXin.model.service.pojos.DomesticResort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 跑腿服务
 * @author 鹏
 */
@Slf4j
@RestController
@RequestMapping("/domestic/resort")
public class DomesticResortController {

    @Autowired
    private DomesticResortService domesticResortService;

    /**
     * 发布求助帖
     * @param domesticReleaseDTO
     * @return
     */
    @PostMapping("/add")
    public ResponseResult add(@RequestBody DomesticReleaseDTO domesticReleaseDTO) {
        log.info("接受到前端发送请求数据: {}",domesticReleaseDTO);
        return domesticResortService.add(domesticReleaseDTO);
    }

    /**
     * 删除求助帖
     * @param id
     * @return
     */
    @PostMapping("/delete")
    public ResponseResult delete(@RequestParam("id") Long id) {
        log.info("接受到前端发送请求数据: {}",id);
        return domesticResortService.delete(id);
    }

    /**
     * 审核通过
     * @param id
     * @return
     */
    @PostMapping("/pass")
    public ResponseResult pass(@RequestParam("id") Long id) {
        return domesticResortService.pass(id);
    }

    /**
     * 审核不通过
     * @return
     */
    @PostMapping("/fail")
    public ResponseResult fail(@RequestParam("id") Long id) {
        return domesticResortService.fail(id);
    }

    /**
     * 查询所有正常发布的求助帖
     * @return
     */
    @GetMapping("/list/normal")
    public ResponseResult<List<DomesticResort>> listNormal() {
        return domesticResortService.listNormal();
    }

    /**
     * 查询所有待审核的求助帖
     * @return
     */
    @GetMapping("/list/review")
    public ResponseResult<List<DomesticResort>> listReview() {
        return domesticResortService.listReview();
    }

    /**
     * 查询所有已经撤下或违禁退回的求助帖
     * @return
     */
    @GetMapping("/list/error")
    public ResponseResult<List<DomesticResort>> listError() {
        return domesticResortService.listError();
    }

    /**
     * 查询所有正在订单进行中的求助帖
     * @return
     */
    @GetMapping("/list/order")
    public ResponseResult<List<DomesticResort>> listOrder() {
        return domesticResortService.listOrder();
    }

    /**
     * 根据帖子id查看帖子信息
     * @param id
     * @return
     */
    @GetMapping("/get")
    public ResponseResult<DomesticResort> getById(@RequestParam("id") Long id) {
        return ResponseResult.okResult(domesticResortService.getById(id));
    }

}
